import {
    COUPON_TYPE_FULL,
    COUPON_TYPE_DISCOUNT,
    COUPON_TYPE_CASH,
    COUPON_TYPE_EXCHANGE,
    COUPON_TYPE_PREPAID,
} from './constrants';
export function analyzeCouponType(type, lang = 'zh') {
    let { zh, en } = '';
    switch (type) {
        case COUPON_TYPE_FULL:
            zh = '满减券';
            en = 'Full coupon';
            break;
        case COUPON_TYPE_DISCOUNT:
            zh = '折扣券';
            en = 'Discount coupon';
            break;
        case COUPON_TYPE_CASH:
            zh = '代金券';
            en = 'Cash coupon';
            break;
        case COUPON_TYPE_EXCHANGE:
            zh = '兑换券';
            en = 'Change coupon';
            break;
        case COUPON_TYPE_PREPAID:
            zh = '储值券';
            en = 'Store coupon';
            break;
        default: break;
    }
    switch (lang) {
        case 'zh': return zh;
        case 'en': return en;
        default: return zh;
    }
}
export function analyzeCouponReachAmmount(amount, lang = 'zh') {
    let { zh, en } = '';
    if (amount && amount !== 0) {
        zh = `满${amount}元可用（不含邮费）`;
        en = `usable when reach amount ${amount}`;
    } else {
        zh = '无门槛优惠券';
        en = 'no reach limit';
    }
    switch (lang) {
        case 'zh': return zh;
        case 'en': return en;
        default: return zh;
    }
}
export function getLocalTime(nS, format = 3, is_add0 = false) {
    if (nS) {
        const time = new Date(parseInt(nS, 10) * 1000);
        const y = time.getFullYear();
        const m = time.getMonth() + 1;
        const d = time.getDate();
        const h = time.getHours();
        const mm = time.getMinutes();
        const s = time.getSeconds();
        const [f_y, f_m, f_d, f_h, f_mm, f_s] = is_add0 ?
            [
                y,
                add0(m),
                add0(d),
                add0(h),
                add0(mm),
                add0(s),
            ] : [y, m, d, h, mm, s];
        switch (format) {
            case 2:
                return `${f_y}-${f_m}-${f_d}`;
            case 3:
                return `${f_y}/${f_m}/${f_d}`;
            default:
                return `${f_y}-${f_m}-${f_d} ${f_h}:${f_mm}:${f_s}`;
        }
    }
    return nS;
}
function add0(m) {
    return m < 10 ? `0${m}` : m;
}

